<?php

/**
* alltosun.com 取消收藏 delete.php
* ============================================================================
* 版权所有 (C) 2009-2012 北京互动阳光科技有限公司，并保留所有权利。
* 网站地址: http://www.alltosun.com
* ----------------------------------------------------------------------------
* 许可声明：这是一个开源程序，未经许可不得将本软件的整体或任何部分用于商业用途及再发布。
* ============================================================================
* $Author: 钱有明 (qianym@alltosun.com) $
* $Date: 2012-11-1 上午11:24:38 $
* $Id: delete.php 22493 2013-04-08 07:43:42Z weisd $
*/

class Action
{
    public function __call($action = '', $params = array())
    {
        $id       = AnFilter::filter_string(Request::Post('id'));
        $res_name = AnFilter::filter_string(Request::getParam('res_name'));
        $res_id   = Request::getParam('res_id', 0);
        $user_id  = user_helper::get_user_id();

        if (empty($user_id)) {
            return array('info' => 'error', 'msg' => '对不起，请先登录！');
        }
        if (!$id && (empty($res_name) || empty($res_id))) {
            return array('info' => 'error', 'msg' => '对不起，请选择要操作的资源');
        }

        if ($res_name && $res_id) {
            _model('fav')->delete(array('res_name'=>$res_name, 'res_id'=>$res_id));
        } else {
            $ids = explode(',', $id);
            foreach ($ids as $v) {
                $v = (int)$v;

                if (empty($v)) {
                    continue;
                }

                _model('fav')->delete($v);
            }
        }

        //$fav_ids = fav_helper::get_res_ids('user', $user_id);
        return array('info' => 'ok');
    }
}
?>